<?php
/**
 * 
 * Adds a image to a node
 * @param string $file_drupal_path
 * @param int $uid
 * @param constant $status
 * 
 * Use example
 * if (file_exists ( $_SERVER ['DOCUMENT_ROOT'] . "/sites/default/files/import_files/nombre.gif" )) {
 * $file = new stdClass ();
 * $file->filepath = "sites/default/files/import_files/nombre.gif";
 * $node->field_image= Array (module_helpers_add_existing_file ( $file->filepath ));
 * }
 */
function module_helpers_add_existing_file($file_drupal_path, $uid = 1, $status = FILE_STATUS_PERMANENT) {
	$file = ( object ) array (
			'filename' => basename ( $file_drupal_path ), 
			'filepath' => $file_drupal_path, 
			'filemime' => file_get_mimetype ( $file_drupal_path ), 
			'filesize' => filesize ( $_SERVER ['DOCUMENT_ROOT'] . "/" . $file_drupal_path ), 
			'uid' => $uid, 
			'status' => $status, 
			'timestamp' => time () 
	);
	
	drupal_write_record ( 'files', $file );
	
	return field_file_load ( $file_drupal_path );
}